<%@ page pageEncoding="utf-8" %>
<%@include file="/commons/taglibs.jsp" %>
<!DOCTYPE html>
<html>
<fmt:bundle basename="res">
<head>
    <meta charset="utf-8">
    <title><fmt:message key='gggg'/></title>
    <jsp:include page="/WEB-INF/commons/commons-header.jsp" flush="true"/>
    <style>
        table, table th, .layui-table th {
            text-align: center;
        }
    </style>
</head>
<body>

<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto">

            <div class="layui-form-item">
                <form name="totalForm" id="totalForm">

                    <div class="layui-inline">
                        <label class="layui-form-label" style="width: 80px;"><fmt:message key='ggwz'/></label>
                        <div class="layui-input-inline">
                            <select name="position">
                                <option value="0" <c:if test="${params.position == 0}">selected</c:if>><fmt:message key='qxz'/></option>
                                <option value="1" <c:if test="${params.position == 1}">selected</c:if>><fmt:message key='syhbt'/></option>
                                <option value="2" <c:if test="${params.position == 2}">selected</c:if>><fmt:message key='sytlgg'/></option>
                                <option value="3" <c:if test="${params.position == 3}">selected</c:if>><fmt:message key='syxgg'/></option>
                                <option value="4" <c:if test="${params.position == 4}">selected</c:if>><fmt:message key='spzfcgy'/></option>
                                <option value="5" <c:if test="${params.position == 5}">selected</c:if>><fmt:message key='spzfcgy'/></option>
                                <option value="6" <c:if test="${params.position == 6}">selected</c:if>><fmt:message key='mshdhb'/></option>
                                <option value="7" <c:if test="${params.position == 7}">selected</c:if>><fmt:message key='tjhdhb'/></option>
                                <option value="8" <c:if test="${params.position == 8}">selected</c:if>><fmt:message key='yshdhb'/></option>
                                <option value="9" <c:if test="${params.position == 9}">selected</c:if>><fmt:message key='pthdhb'/></option>
                            </select>
                        </div>
                    </div>


                    <div class="layui-inline">
                        <label class="layui-form-label" style="width: 80px;"><fmt:message key='ggmc'/></label>
                        <div class="layui-input-inline">
                            <input type="text" name="name" value="${params.name}" class="layui-input">
                        </div>
                    </div>

                    <div class="layui-inline">
                        <label class="layui-form-label" style="width: 80px;"><fmt:message key='zt'/></label>
                        <div class="layui-input-inline">
                            <select name="status">
                                <option value="0" <c:if test="${params.status == 0}">selected</c:if>><fmt:message key='qxz'/></option>
                                <option value="1" <c:if test="${params.status == 1}">selected</c:if>><fmt:message key='ysj'/></option>
                                <option value="2" <c:if test="${params.status == 2}">selected</c:if>><fmt:message key='yxj'/></option>
                            </select>
                        </div>
                    </div>

<%--                    <div class="layui-inline">--%>
<%--                        <label class="layui-form-label" style="width: 80px;"><fmt:message key='ptlx'/></label>--%>
<%--                        <div class="layui-input-inline">--%>
<%--                            <select name="platformType">--%>
<%--                                <option value="0" <c:if test="${params.platformType == 0}">selected</c:if>><fmt:message key='scd'/></option>--%>
<%--                                <option value="1" <c:if test="${params.platformType == 1}">selected</c:if>><fmt:message key='cgd'/></option>--%>
<%--                            </select>--%>
<%--                        </div>--%>
<%--                    </div>--%>

                    <div class="layui-inline">
                        <button class="layui-btn layui-btn-sm layuiadmin-btn-list" id="search"><i class="layui-icon layui-icon-search layuiadmin-button-btn"></i> <fmt:message key='ss'/></button>
                    </div>
                </form>
            </div>
        </div>

    </div>

    <div class="layui-card">
        <div class="layui-field-box layui-form">
            <shiro:hasPermission name="advertis:create">
                <a href="javascript:void(0);" class="layui-btn layui-btn-sm layui-btn-normal" id="add"><i class="layui-icon">&#xe61f;</i> <fmt:message key='xzgg'/></a>
            </shiro:hasPermission>
            <shiro:hasPermission name="advertis:enables">
                <a href="javascript:void(0);" class="layui-btn layui-btn-sm layui-btn-warm" id="enables"><i class="layui-icon">&#xe605;</i> <fmt:message key='plsj'/></a>
            </shiro:hasPermission>
            <shiro:hasPermission name="advertis:disables">
                <a href="javascript:void(0);" class="layui-btn layui-btn-sm layui-btn-danger" id="disables"><i class="layui-icon">&#x1006;</i> <fmt:message key='plxj'/></a>
            </shiro:hasPermission>

            <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
                <ul class="layui-tab-title">
                    <li <c:if test="${params.position eq 0}">class="layui-this"</c:if> >
                        <a href="${web_domain}/mall/advertis/list"
                           <c:if test="${params.position eq 0}">style="color: rgb(0, 150, 136)"</c:if> >全部</a>
                    </li>
                    <li <c:if test="${params.position eq 1}">class="layui-this"</c:if>>
                        <a href="${web_domain}/mall/advertis/list?position=1" <c:if test="${params.position eq 1}">style="color: rgb(0, 150, 136)"</c:if>><fmt:message key='syhb'/></a>
                    </li>
                    <li <c:if test="${params.position eq 2}">class="layui-this"</c:if>>
                        <a href="${web_domain}/mall/advertis/list?position=2" <c:if test="${params.position eq 2}">style="color: rgb(0, 150, 136)"</c:if>><fmt:message key='sytlgg'/></a>
                    </li>
                    <li <c:if test="${params.position eq 3}">class="layui-this"</c:if>>
                        <a href="${web_domain}/mall/advertis/list?position=3" <c:if test="${params.position eq 3}">style="color: rgb(0, 150, 136)"</c:if>><fmt:message key='syxgg'/></a>
                    </li>
                    <li <c:if test="${params.position eq 4}">class="layui-this"</c:if>>
                        <a href="${web_domain}/mall/advertis/list?position=4" <c:if test="${params.position eq 4}">style="color: rgb(0, 150, 136)"</c:if>><fmt:message key='spzfcgygg'/></a>
                    </li>
                    <li <c:if test="${params.position eq 5}">class="layui-this"</c:if>>
                        <a href="${web_domain}/mall/advertis/list?position=5" <c:if test="${params.position eq 5}">style="color: rgb(0, 150, 136)"</c:if>><fmt:message key='ljzz'/></a>
                    </li>
                    <li <c:if test="${params.position eq 6}">class="layui-this"</c:if>>
                        <a href="${web_domain}/mall/advertis/list?position=6" <c:if test="${params.position eq 6}">style="color: rgb(0, 150, 136)"</c:if>><fmt:message key='mshd'/></a>
                    </li>
                    <li <c:if test="${params.position eq 7}">class="layui-this"</c:if>>
                        <a href="${web_domain}/mall/advertis/list?position=7" <c:if test="${params.position eq 7}">style="color: rgb(0, 150, 136)"</c:if>><fmt:message key='tjhd'/></a>
                    </li>
                    <li <c:if test="${params.position eq 8}">class="layui-this"</c:if>>
                        <a href="${web_domain}/mall/advertis/list?position=8" <c:if test="${params.position eq 8}">style="color: rgb(0, 150, 136)"</c:if>><fmt:message key='yshd'/></a>
                    </li>
                    <li <c:if test="${params.position eq 9}">class="layui-this"</c:if>>
                        <a href="${web_domain}/mall/advertis/list?position=9" <c:if test="${params.position eq 9}">style="color: rgb(0, 150, 136)"</c:if>><fmt:message key='pthd'/></a>
                    </li>
                </ul>
            </div>

            <table class="layui-table" lay-size="sm">
                <thead>
                <tr>
                    <th width="5%"><input id="checkboxs" type="checkbox" lay-ignore lay-skin="primary"/></th>
                    <th width="5%"></c:if>><fmt:message key='xh'/></th>
                    <th><fmt:message key='ptlx'/></th>
                    <th><fmt:message key='ggwz'/></th>
                    <th><fmt:message key='ggmc'/></th>
                    <th><fmt:message key='fmt'/></th>
                    <th><fmt:message key='cjsj'/></th>
                    <th><fmt:message key='pxz'/></th>
                    <th><fmt:message key='zt'/></th>
                    <th><fmt:message key='cz'/></th>
                </tr>
                </thead>
                <c:forEach items="${page}" var="item" varStatus="status">
                    <tr>
                        <td><input type="checkbox" lay-ignore value="${item.id}" class="feijin-check" lay-skin="primary"/></td>
                        <td>${status.index + 1}</td>
                        <td>
                            <c:if test="${item.platformType == 0}"><fmt:message key='scd'/></c:if>
                            <c:if test="${item.platformType == 1}"><fmt:message key='cgd'/></c:if>
                        </td>
                        <td>
                            <c:choose>
                                <c:when test="${item.position == 1}"><fmt:message key='syhbt'/></c:when>
                                <c:when test="${item.position == 2}"><fmt:message key='sytlgg'/></c:when>
                                <c:when test="${item.position == 3}"><fmt:message key='syxgg'/></c:when>
                                <c:when test="${item.position == 4}"><fmt:message key='spzfcgy'/></c:when>
                                <c:when test="${item.position == 5}"><fmt:message key='ljzz'/></c:when>
                                <c:when test="${item.position == 6}"><fmt:message key='mshd'/></c:when>
                                <c:when test="${item.position == 7}"><fmt:message key='tjhd'/></c:when>
                                <c:when test="${item.position == 8}"><fmt:message key='yshd'/></c:when>
                                <c:when test="${item.position == 9}"><fmt:message key='pthd'/></c:when>
                            </c:choose>
                        </td>
                        <td>${item.name}</td>
                        <td><img class="preview" src="${store_domain}/uploads/${item.image}"></td>
                        <td><fmt:formatDate value="${item.createTime}" type="both"/></td>
                        <td>${item.rank}</td>
                        <td>
                            <c:if test="${item.status == 1}"><b style="color: #f00;"><fmt:message key='yxj'/></b></c:if>
                            <c:if test="${item.status == 2}"><b style="color: green;"><fmt:message key='ysj'/></b></c:if>
                        </td>
                        <td>
                            <div class="layui-btn-container">
                                <c:choose>
                                    <c:when test="${item.status == 2}">
                                        <shiro:hasPermission name="advertis:disable">
                                            <a href="javascript:void(0);" data-id="${item.id}" class="layui-btn layui-btn-danger layui-btn-xs feijin-disable"><fmt:message key='xj'/></a>
                                        </shiro:hasPermission>
                                    </c:when>
                                    <c:otherwise>
                                        <shiro:hasPermission name="advertis:enabled">
                                            <a href="javascript:void(0);" data-id="${item.id}" class="layui-btn layui-btn-normal layui-btn-xs feijin-enabled"><fmt:message key='sj'/></a>
                                        </shiro:hasPermission>
                                    </c:otherwise>
                                </c:choose>
                                <shiro:hasPermission name="advertis:modify">
                                    <a href="javascript:void(0);" data-id="${item.id}" class="layui-btn layui-btn-normal layui-btn-xs feijin-modify"><fmt:message key='bj'/></a>
                                </shiro:hasPermission>
                                <shiro:hasPermission name="advertis:remove">
                                    <a href="javascript:void(0);" data-id="${item.id}" class="layui-btn layui-btn-danger layui-btn-xs feijin-remove"><fmt:message key='sc'/></a>
                                </shiro:hasPermission>
                            </div>
                        </td>
                    </tr>
                </c:forEach>
            </table>
            <%--<jsp:include page="/commons/page.jsp" flush="true"/>--%>
        </div>
    </div>

</div>

<script>

    layui.use("layer", function () {

        //添加
        $("#add").click(function () {
            layer.open({
                type: 2,
                title: "<fmt:message key='xzgg'/>",
                content: "${web_domain}/mall/advertis/create",
                area: ["90%", "90%"],
                btn: ["<fmt:message key='qd'/>", "<fmt:message key='qx'/>"],
                yes: function (index, layero) {
                    layero.find('iframe').contents().find("#submit").click();
                }
            });
        });

        //编辑
        $(".feijin-modify").click(function () {
            var id = $(this).attr("data-id");
            layer.open({
                type: 2,
                content: "${web_domain}/mall/advertis/modify?id=" + id,
                area: ["90%", "90%"],
                btn: ["<fmt:message key='qd'/>", "<fmt:message key='qx'/>"],
                yes: function (index, layero) {
                    layero.find('iframe').contents().find("#submit").click();
                }
            });
        });

        //下架
        $(".feijin-disable").click(function () {
            var id = $(this).attr("data-id");
            layer.confirm("<fmt:message key='qrxjm?'/>", function () {
                feijin.put({
                    url: "${web_domain}/mall/advertis/disable",
                    data: {id: id}
                });
            });
        });

        //上架
        $(".feijin-enabled").click(function () {
            var id = $(this).attr("data-id");
            layer.confirm("<fmt:message key='qrsjm?'/>", function () {
                feijin.put({
                    url: "${web_domain}/mall/advertis/enable",
                    data: {id: id}
                });
            });
        });


        //删除
        $(".feijin-remove").click(function () {
            var id = $(this).attr("data-id");
            layer.confirm("<fmt:message key='qrscm?'/>", function () {
                feijin.delete({
                    url: "${web_domain}/mall/advertis/remove",
                    data: {"id": id}
                });
            });
        })

        //全选反选
        $("#checkboxs").click(function () {
            if (this.checked) {
                $(".feijin-check:checkbox").prop("checked", true);
            } else {
                $(".feijin-check:checkbox").prop("checked", false);
            }
        });


        //批量上架账号
        $("#enables").click(function () {
            var ids = [];

            $(".feijin-check:checkbox:checked").each(function (index, item) {
                var id = $(item).val();
                ids.push(id);
            });

            if (ids.length === 0) {
                layer.msg('<fmt:message key='qxgxxyczdjl'/>');
                return false;
            }

            layer.confirm("<fmt:message key='qrsjxzdggm?'/>?", function () {
                feijin.put({
                    url: "${web_domain}/mall/advertis/enables",
                    data: {"data": ids.join(";")}
                });
            });
        });

        //批量下架账号
        $("#disables").click(function () {
            var ids = [];

            $(".feijin-check:checkbox:checked").each(function (index, item) {
                var id = $(item).val();
                ids.push(id);
            });

            if (ids.length === 0) {
                layer.msg('<fmt:message key='qxgxxyczdjl'/>');
                return false;
            }

            layer.confirm("<fmt:message key='qrxjxzdggm?'/>", function () {
                feijin.put({
                    url: "${web_domain}/mall/advertis/disables",
                    data: {"data": ids.join(";")}
                });
            });
        });

    });
</script>
</body>
</fmt:bundle>
</html>
